package android.demo.service.aidl;

import android.content.Intent;
import android.demo.Constants.Action;
import android.demo.service.BaseService;
import android.demo.service.aidl.impl.ContactGroupServiceImpl;
import android.demo.service.aidl.impl.ContactServiceImpl;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class RemoteService extends BaseService {

	private IContactService.Stub contactService = new ContactServiceImpl();
	private Binder contactGroupService = new ContactGroupServiceImpl();
	
	@Override
	public IBinder onBind(Intent intent) {
		Log.i(TAG, this + "@" + android.os.Process.myPid() + "@" + android.os.Process.myTid() + "....................onBind");
		
		if (intent.getAction().equals(Action.SERVICE_CONTACT_SERVICE)) {
			return contactService;				
		} else if (intent.getAction().equals(Action.SERVICE_CONTACT_GROUP_SERVICE)) {
			return contactGroupService;			
		} else {
			return contactService;
		}
	}
}
